﻿@model AntUnion.FrameWork.Model.Models.CrmWithdrawal
@{
    ViewData["Title"] = "CashVerificationDetail";
    Layout = "~/Areas/Console/Views/Shared/_Layout.cshtml";
}
@section head{
    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script type="text/javascript">
        var renderTable;
        var setSelectData;
        var userType = 0;

        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            treetable: 'treetable-lay/treetable',
            index: 'lib/index'
        }).use(['table', 'treetable', 'index', 'laydate', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                , table = layui.table
                , element = layui.element
                , laydate = layui.laydate;

            /**多语言初始化 */
            top.SetFormPageLanguage(layui);



            form.on('submit(identityInfoConfirmBtn)', function (data) {
                /**提示语弹框 */
                var State = $('input[name ="State"]:checked').val();
                if (typeof (State) == "undefined") {
                    top.AlertByKey(layui, "pleaseSelectStatus", 0);
                    return false;
                }
                if (State == 2) {
                    if ($('#toamount').val() == "" || $('#toamount').val() == "0") {
                        top.AlertByKey(layui, "promptAmount", 0);
                        return false;

                    }
                    var deposit_amount = $('#deposit_amount').val() * 1;
                    var toamount = $('#toamount').val() * 1;
                    if (toamount < 0 || deposit_amount < toamount) {
                        top.AlertByKey(layui, "withdrawalAmountError", 0);
                        return false;

                    }

                }
                layui.layer.confirm(top.lang.confirmExecute, {
                    title: top.lang.cashVerification,
                    btn: [top.lang.confirmBtn, top.lang.closeBtn]
                }, function (index, layero) {
                    $.ajax({
                        type: "POST",
                        url: "/Console/CashVerification/Edit",
                        data: {
                            "Id": $('#Id').val(),
                            "State": State,
                            "Remarks": $('#remarks').val(),
                            "Toamount": $('#toamount').val()
                        },
                        async: true,
                        error: function (request) {
                            alert("Connection error");
                        },
                        beforeSend: function (xhr) {
                            layui.layer.load();
                        },
                        success: function (data) {
                            var item = eval(data);
                            if (item.code == 0) {
                                /**提示语弹框 */
                                top.ShowMessageByKey(layui, "submitSuccess", 6, 1000, function () {
                                    parent.layui.index.openTabsPage("/Console/CashVerification/Index");
                                    parent.layui.admin.events.refresh();
                                    top.delectTable("layadmin-layout-tabs", "/Console/CashVerification/CashVerificationDetail?id=" + $("#Id").val());
                                });

                            } else {
                                /**提示语弹框 */
                                top.AlertByKey(layui, item.msg, 0);
                            }
                            layer.closeAll('loading');
                        }
                    });
                });

                return false;
            });
            form.on("radio(State)", function (data) {
                var contact = data.value;
                console.log(contact);
                if (contact == 2) {
                    $("#isShow").show();
                } else {
                    $("#isShow").hide();
                }

            });

            form.on('submit(identityInfoCancel)', function (data) {
                parent.layui.admin.events.closeThisTabs();
                parent.layui.index.openTabsPage("/Console/CashVerification/Index", top.lang.certificationAudit);
            });

            //光标离开输入的金额四舍五入并保留2位小数
            $("#toamount").blur(function () {
                var obj = this.value;
                var mnyReg = /^([1-9][0-9]*|(([0]\.[0-9]{0,2}[1-9]\d*|[1-9][0-9]*\.\d*)))$/;//根据需求修改
                if (!(mnyReg.test(obj))) {
                    top.AlertByKey(layui, "enterNotIsNumber", 0);
                    return;
                }
                var n = 2; //保留得小数位
                obj = parseFloat(obj).toFixed(n);
                var left = obj.split(".")[0].split("").reverse();
                var right = obj.split(".")[1];
                var total = new Array();
                for (i = 0; i < left.length; i++) {
                    total.push(left[i]);
                    if ((i + 1) % 3 == 0 && (i + 1) != left.length) {
                        total.push(",");
                    }
                }
                $("#toamount").val(total.reverse().join("") + "." + right);
            });

            //光标进入，去除金额千分位，并去除小数后面多余的0
            $("#toamount").focus(function () {
                var oldMny = this.value.replace(/,/g, '');
                if (oldMny.indexOf(".") > 0) {
                    oldMny = oldMny.replace(/0+?$/, "");//去除尾部多余的0
                    oldMny = oldMny.replace(/[.]$/, "");//如果最后一位是.则去掉
                }
                this.value = oldMny;
            });


        });

    </script>
}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend lay-event='accountInformation'>账户信息</legend>
                    </fieldset>
                    <div class="layui-form">
                        <div class="layui-row layui-col-space10 layui-form-item">
                            @if (ViewBag.crmUsers != null)
                            {
                                AntUnion.FrameWork.Model.Models.CrmUser crmUser = ViewBag.crmUsers as AntUnion.FrameWork.Model.Models.CrmUser;

                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event='fullName'>姓名：</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmUser.Name</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event='CRMAccount'>账户ID：</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmUser.LoginName</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event='MT5Account'>MT5账户：</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@Model.Login</div>
                                    </div>
                                </div>
                            }
                        </div>
                    </div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend lay-event='cashOutInformation'>出金信息</legend>
                    </fieldset>
                    <div class="layui-form">
                        <div class="layui-row layui-col-space10 layui-form-item">

                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="paymentMethod">出金方式</label>
                                <div class="layui-input-block">
                                    @if (Model.Mothod == 1)
                                    {
                                        <div class="layui-form-mid " id="wireTransfer" name="wireTransfer" lay-event="wireTransfer">电汇账户</div>
                                    }
                                    else if (Model.Mothod == 2)
                                    {
                                        <div class="layui-form-mid " id="remittanceAccount" name="remittanceAccount" lay-event="remittanceAccount">汇款账户</div>
                                    }
                                    else
                                    {
                                        <div class="layui-form-mid " id="cryptocurrency" name="cryptocurrency" lay-event="cryptocurrency">加密货币</div>
                                    }

                                </div>
                            </div>
                            @*<div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="cashOutAccount">出金账号</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@Model.FromAmountCurrency</div>
                                    </div>
                                </div>*@
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="paymentAmount">出金金额</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@ViewBag.paymentAmount</div>
                                </div>
                            </div>
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="commission">手续费</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@ViewBag.commission</div>
                                </div>
                            </div>
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="exchangeRate">汇率</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@ViewBag.exchangeRate</div>
                                </div>
                            </div>
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="receivedAmount">到账金额</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@ViewBag.receivedAmount</div>
                                </div>
                            </div>
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="remark">备注</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@Model.Remark</div>
                                </div>
                            </div>
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="orderNumber">订单号</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@Model.Id</div>
                                </div>
                            </div>
                            @if (ViewBag.crmWireTransfer != null)
                            {
                                AntUnion.FrameWork.Model.Models.CrmWireTransfer crmWireTransfer = ViewBag.crmWireTransfer as AntUnion.FrameWork.Model.Models.CrmWireTransfer;
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="currencyReceipt">收款货币</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmWireTransfer.Currency</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="payee">收款人</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmWireTransfer.Payee</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="payeeNumber">收款账号</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmWireTransfer.AccountNumber</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="payeeAddress">收款人地址</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmWireTransfer.Currency</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="receivingBank">收款银行</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmWireTransfer.Bank</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="swiftcode">SWIFT Code</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmWireTransfer.Swiftcode</div>
                                    </div>
                                </div>
                            }
                            @if (ViewBag.crmRemittanceAccount != null)
                            {
                                AntUnion.FrameWork.Model.Models.CrmRemittanceAccount crmRemittanceAccount = ViewBag.crmRemittanceAccount as AntUnion.FrameWork.Model.Models.CrmRemittanceAccount;
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="currencyReceipt">收款货币</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmRemittanceAccount.Currency</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="accountName">开户姓名</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmRemittanceAccount.Payee</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="accountNumber">银行卡号</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmRemittanceAccount.AccountNumber</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="bank">开户银行</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmRemittanceAccount.Bank</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="branchName">支行名称</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmRemittanceAccount.BranchName</div>
                                    </div>
                                </div>
                            }
                            @if (ViewBag.crmCryptocurrency != null)
                            {
                                AntUnion.FrameWork.Model.Models.CrmCryptocurrency crmCryptocurrency = ViewBag.crmCryptocurrency as AntUnion.FrameWork.Model.Models.CrmCryptocurrency;
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="currencyReceipt">收款货币</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmCryptocurrency.Currency</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="currencyReceipt">网络</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmCryptocurrency.Network</div>
                                    </div>
                                </div>
                                <div class="layui-col-lg6">
                                    <label class="layui-form-label" lay-event="currencyReceipt">收款地址</label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@crmCryptocurrency.ReceivingAddress</div>
                                    </div>
                                </div>

                            }
                            <div class="layui-col-lg6">
                                <label class="layui-form-label" lay-event="creationTime">创建时间</label>
                                <div class="layui-input-block">
                                    <div class="layui-form-mid ">@Model.CreateDate</div>
                                </div>
                            </div>

                        </div>
                    </div>


                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend lay-event='auditRecords'>审核记录</legend>
                    </fieldset>
                    <div class="layui-form">
                        <div class="layui-row layui-col-space10 layui-form-item">
                            <ul class="layui-timeline">
                                @if (ViewBag.crmAuditLogsList != null)
                                {
                                    List<AntUnion.FrameWork.Model.Models.CrmAuditLog> crmAuditLogs = ViewBag.crmAuditLogsList as List<AntUnion.FrameWork.Model.Models.CrmAuditLog>;
                                    foreach (AntUnion.FrameWork.Model.Models.CrmAuditLog crmAuditLog in crmAuditLogs)
                                    {
                                        <li class="layui-timeline-item">
                                            <i class="layui-icon layui-timeline-axis"></i>
                                            <div class="layui-timeline-content layui-text">
                                                <h3 class="layui-timeline-title">@crmAuditLog.CreateDate</h3>
                                                <p>
                                                    @crmAuditLog.Reviewer  @crmAuditLog.Cont<br />
                                                    @if (!string.IsNullOrEmpty(crmAuditLog.Remark))
                                                    {
                                                        @Html.Raw("备注:") @crmAuditLog.Remark
                                                    }
                                                </p>
                                            </div>
                                        </li>

                                    }
                                }
                            </ul>
                        </div>
                    </div>

                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend lay-event='toExamine'>审核</legend>
                        <div class="layui-form">
                            <div class="layui-row layui-col-space10 layui-form-item">
                                <div class="layui-col-lg10">
                                    <label class="layui-form-label" style="width:120px" lay-event='currentReviewer'>
                                        当前审核人：
                                    </label>
                                    <div class="layui-input-block">
                                        <div class="layui-form-mid ">@ViewBag.LoginName</div>
                                        <input id="reviewer" name="reviewer" type="hidden" value="@ViewBag.LoginName" />
                                    </div>
                                </div>
                                <div class="layui-col-lg10">
                                    <label class="layui-form-label" lay-event='currentAuditStatus' style="width:120px">当前审核状态</label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="State" lay-filter="State" value="2" title="通过" lay-event='pass' @Html.Raw(Model.State == 2 ? " checked=\"checked\"" : "")>
                                        <input type="radio" name="State" lay-filter="State" value="1" title="拒绝" lay-event='refuse' @Html.Raw(Model.State == 1 ? " checked=\"checked\"" : "")>
                                    </div>
                                </div>
                                <div class="layui-col-lg10" id="isShow" style="@Html.Raw(Model.State == 2 ? "" : "display:none") ">
                                    <label class="layui-form-label" lay-event='receivedAmount' style="width:120px">到账金额</label>
                                    <div class="layui-input-block">
                                        <input id="deposit_amount" name="deposit_amount" type="hidden" value="@Model.WithdrawalAmount" />
                                        <input type="text" name="toamount" id="toamount" lay-verify="title" style="width:70%" autocomplete="off" class="layui-input" value="@ViewBag.receivedAmount">
                                    </div>
                                </div>
                                <div class="layui-col-lg10">
                                    <label class="layui-form-label" lay-event='remark' style="width:120px">备注</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="remarks" id="remarks" lay-verify="title" style="width:70%" autocomplete="off" placeholder="refusalToFillInPrompt" class="layui-input" value="">
                                    </div>
                                </div>

                            </div>
                        </div>
                    </fieldset>
                    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                        <legend></legend>
                    </fieldset>
                    <div class="layui-form">
                        <div class="layui-input-block">
                            <input id="Id" name="Id" type="hidden" value="@Model.Id" />
                            @if (Model.State == 0)
                            {
                                <button class="layui-btn" id="confirmBtn" lay-event="confirmBtn" lay-submit lay-filter="identityInfoConfirmBtn">确认</button>
                            }
                            <button class="layui-btn layui-btn-primary" id="goBack" lay-event="goBack" lay-submit lay-filter="identityInfoCancel">返回</button>

                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
